package com.ssy.lingxi.platform.template.service.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.door.Seo;
import com.ssy.lingxi.platform.template.service.model.dto.common.CommonStatusDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.web.SaveSeoDTO;
import com.ssy.lingxi.platform.template.service.model.qo.SeoQO;
import com.ssy.lingxi.platform.template.service.service.web.SeoWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu web - SEO
 * @author fhj
 * @version 2.0.0
 * @date 2021/04/15
 */
@Api(tags = "web - SEO")
@RestController
@RequestMapping("/template/web/seoWeb")
public class SeoWebController extends BaseController {

    @Resource
    private SeoWebService seoWebService;

    @ApiOperation(value = "列表")
    @GetMapping("/page")
    public Wrapper<PageData<Seo>> page(@Valid SeoQO qo) {
        return seoWebService.page(qo, getSysUser());
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/get")
    public Wrapper<Seo> get(@Valid IdDTO dto) {
        return seoWebService.get(dto, getSysUser());
    }

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Validated({SaveSeoDTO.Add.class}) SaveSeoDTO dto) {
        return seoWebService.add(dto, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({SaveSeoDTO.Update.class}) SaveSeoDTO dto) {
        return seoWebService.update(dto, getSysUser());
    }

    @ApiOperation(value = "停用/启用")
    @PostMapping(value = "/updateStatus")
    public Wrapper<Void> updateStatus(@RequestBody @Valid CommonStatusDTO dto) {
        return seoWebService.updateStatus(dto, getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Valid IdDTO dto) {
        return seoWebService.delete(dto, getSysUser());
    }
}
